home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWPictur.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  6.1 KB  |  208 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPictur.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWPICTUR_H
  11. #define FWPICTUR_H
  12.  
  13. #ifndef FWGROBJ_H
  14. #include "FWGrObj.h"
  15. #endif
  16.  
  17. #ifndef FWGC_H
  18. #include "FWGC.h"
  19. #endif
  20.  
  21. #ifndef FWRESOUR_H
  22. #include "FWResour.h"
  23. #endif
  24.  
  25. #ifndef FWPRIEXC_H
  26. #include "FWPriExc.h"
  27. #endif
  28.  
  29. #if FW_LIB_EXPORT_PRAGMAS
  30. #pragma lib_export on
  31. #endif
  32.  
  33. //========================================================================================
  34. // Error codes
  35. //========================================================================================
  36.  
  37. const FW_PlatformError FW_xInvalidPictureData = -30022;
  38.  
  39. //========================================================================================
  40. //    Forward Class Declarations
  41. //========================================================================================
  42.  
  43. class FW_CLASS_ATTR FW_CPictureRep;
  44. class FW_CLASS_ATTR FW_CPictureContext;
  45. class FW_CLASS_ATTR FW_GraphicDevice;
  46.  
  47. //========================================================================================
  48. //    class FW_PPicture
  49. //========================================================================================
  50.  
  51. class FW_CLASS_ATTR FW_PPicture : public FW_CGraphicCountedPtr
  52. {
  53. public:
  54.     FW_DECLARE_CLASS
  55.  
  56. public:
  57.     FW_PPicture();
  58.     virtual ~ FW_PPicture();
  59.     
  60.     FW_PPicture(FW_PlatformPict platformPict);
  61.     FW_PPicture(FW_CResourceFile& resourceFile, FW_ResourceId resourceId);
  62.     
  63.     FW_PPicture(const FW_PPicture& other);
  64.     FW_PPicture(FW_CPictureRep* rep);
  65.     
  66.     FW_PPicture& operator=(const FW_PPicture& other);
  67.     FW_PPicture& operator=(FW_CPictureRep* other);
  68.         
  69.     FW_CPictureRep* operator->();
  70.     const FW_CPictureRep* operator->() const;
  71. };
  72.  
  73. //========================================================================================
  74. //    class FW_CPictureRep
  75. //========================================================================================
  76.  
  77. class FW_CLASS_ATTR FW_CPictureRep : public FW_CGraphicCountedPtrRep
  78. {
  79.     friend class FW_CLASS_ATTR FW_PPicture;
  80.  
  81. public:
  82.     FW_DECLARE_CLASS
  83.  
  84. //----------------------------------------------------------------------------------------
  85. //    Constructors/Destructors
  86. //
  87. private:
  88.     FW_CPictureRep();
  89.     FW_CPictureRep(FW_CReadableStream& archive);                            // fOwnPicture = TRUE
  90.     FW_CPictureRep(FW_CResourceFile& resourceFile, FW_ResourceId resId);    // fOwnPicture = TRUE
  91.     
  92.     FW_CPictureRep(FW_PlatformPict platformPict);                            // fOwnPicture = FALSE
  93.  
  94.     virtual ~FW_CPictureRep();
  95.  
  96. //----------------------------------------------------------------------------------------
  97. //    Inherited API
  98. //
  99. public:
  100.     virtual void            Flatten(FW_CWritableStream& archive) const;
  101.     virtual FW_Boolean        IsEqual(const FW_CGraphicCountedPtrRep* other) const;
  102.     
  103. //----------------------------------------------------------------------------------------
  104. //    New API
  105. //
  106. public:
  107.     // ----- Copying -----
  108.     FW_PPicture                Copy() const;
  109.     
  110.     // ----- Get, Set, Adopt and Orphan
  111.     FW_PlatformPict            GetPlatformPict() const;                            // return fPlatformPict
  112.     FW_Boolean                IsPlatformPictOrphan() const;
  113.     FW_PlatformPict            OrphanPlatformPict();                                // return fPlatformPict, and change ownership 
  114.     
  115.     void                    SetPlatformPict(FW_PlatformPict newPict);            // fOwnPicture = FALSE
  116.     void                    AdoptPlatformPict(FW_PlatformPict newPict);            // fOwnPicture = TRUE
  117.     
  118.     void                    LoadPictureFromResource(FW_CResourceFile& resourceFile,
  119.                                                     FW_ResourceId resourceId);    // fOwnPicture = TRUE
  120.                                                     
  121.     // ----- Getter/Setter -----
  122.     void                    GetPictBounds(FW_CRect& bounds) const;                            // Size in pixels
  123.     void                    GetPictBounds(FW_CGraphicContext& gc, FW_CRect& bounds) const;    // Size in gc units
  124.     
  125.     // ----- Archiving -----
  126.     static void*            Read(FW_CReadableStream& archive);
  127.  
  128.     void                    WriteTo(const FW_CWritableStream& stream) const;
  129.     void                    ReadFrom(const FW_CReadableStream& stream);
  130.  
  131. #ifdef FW_BUILD_MAC
  132.     void                    MacLock();
  133.     void                    MacUnlock();
  134. #endif
  135.  
  136. protected:
  137.     void                    DisposePlatformPict();
  138.     
  139. //----------------------------------------------------------------------------------------
  140. //    Data Members
  141. //
  142. private:
  143.     FW_Boolean            fOwnPicture;
  144.     FW_PlatformPict     fPlatformPict;
  145.     
  146. #ifdef FW_BUILD_MAC
  147.     unsigned short    fMacLockCount;
  148. #endif
  149. };
  150.  
  151. //========================================================================================
  152. //    class FW_CPictureContext
  153. //========================================================================================
  154.  
  155. class FW_CLASS_ATTR FW_CPictureContext : public FW_CGraphicContext
  156. {
  157. public:
  158.     FW_CPictureContext(Environment* ev,
  159.                        FW_PPicture& picture,
  160.                        FW_CFixed xSize,
  161.                        FW_CFixed ySize);
  162.                                            // Size is in 72dpi
  163.     virtual ~FW_CPictureContext();
  164.  
  165. private:
  166.     FW_PPicture&         fPicture;        // A reference because will modify the ref-cnt pointer
  167.     FW_CGraphicDevice*    fGraphicDevice;
  168.     
  169. #ifdef FW_BUILD_MAC
  170.     PicHandle             fMacPictHandle;
  171. #endif
  172. };
  173.  
  174. //========================================================================================
  175. //    Inlines
  176. //========================================================================================
  177.  
  178. //----------------------------------------------------------------------------------------
  179. //    FW_PPicture::operator->
  180. //----------------------------------------------------------------------------------------
  181. inline FW_CPictureRep* FW_PPicture::operator->()
  182. {
  183.     return (FW_CPictureRep*) GetRep();
  184. }
  185.  
  186. //----------------------------------------------------------------------------------------
  187. //    FW_PPicture::operator->
  188. //----------------------------------------------------------------------------------------
  189. inline const FW_CPictureRep* FW_PPicture::operator->() const
  190. {
  191.     return (const FW_CPictureRep*) GetRep();
  192. }
  193.  
  194. //----------------------------------------------------------------------------------------
  195. //    FW_CPictureRep::IsPlatformPictOrphan
  196. //----------------------------------------------------------------------------------------
  197. inline FW_Boolean FW_CPictureRep::IsPlatformPictOrphan() const
  198. {
  199.     return !fOwnPicture;
  200. }
  201.  
  202.  
  203. #if FW_LIB_EXPORT_PRAGMAS
  204. #pragma lib_export off
  205. #endif
  206.  
  207. #endif
  208.